﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using RLZY.others;
using System.Reflection;

namespace RLZY
{
    public partial class Form关键固定项修改 : Form
    {
        public Form关键固定项修改()
        {
            InitializeComponent();
        }




        public bool flesh = false;
        public bool returnflesh()
        {
            return this.flesh;
        }






        public bool NameIDIS_Exist()
        {
            others.NotKey not = new NotKey();
            SqlDataReader re = not.GetListNameId(this.txtNameID.Text.Trim());
            if (re.Read())
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        public bool ZHIS_Exist()
        {
            others.NotKey not = new NotKey();
            SqlDataReader re = not.GetListZH(this.txtZH.Text.Trim());
            if (re.Read())
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        Model.GZ model = new Model.GZ();
        static log4net.ILog LOG = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        
        private void Form关键固定项修改_Load(object sender, EventArgs e)
        {
            
            try
            {
                BLL.userpassword bllpwd = new BLL.userpassword();
                Model.userpassword modelpwd = bllpwd.GetModel(Convert.ToInt32(others.UserHelper.UserID));
                others.myGZ mygz = new myGZ();
                权限 = model.备注;

                BLL.GZ bll = new BLL.GZ();
                model = bll.GetModel(Convert.ToInt32(others.UserHelper.GZID));
                dtpDate.Text = model.日期;
                txtBM.Text = model.部门单位;
                txtBZ.Text = model.车间班组;
                txtYGXZ.Text = model.用工性质;
                txtName.Text = model.姓名;
                txtLT.Text = model.粮贴.ToString();
                txtXLF.Text = model.洗理费.ToString();
                txtSDQBT.Text = model.水电气补贴.ToString();
                txtHT.Text = model.回贴.ToString();
                txtZCJT.Text = model.职称津贴.ToString();
                txtTGJT.Text = model.特岗津贴.ToString();
                txtHCGJT.Text = model.行车工津贴.ToString();
                txtWSZF.Text = model.卫生纸费.ToString();
                txtKDSF.Text = model.扣电视费.ToString();
                txtKZAF.Text = model.扣治安费.ToString();
                txtKHF.Text = model.扣会费.ToString();
                txtKHZJ.Text = model.扣互助金.ToString();
                txtKSZF.Text = model.扣丧葬费.ToString();
                txtGW.Text = model.岗位名称;
                txtSex.Text = model.性别;
                dtpWorkDate.Text = model.参加工作时间;
                txtGH.Text = model.工号;
                txtNameID.Text = model.身份证号;
                txtZH.Text = model.帐号;
                txtLGH.Text = model.老工号;
                txtBeiZu.Text = model.备注;
                txtGJJ.Text = model.公积金号;
                txtYLBX.Text = model.医疗保险号;
                this.dtpBorn.Text = model.出生日期;
                this.cmbDZZB.Text = model.党政职别;
                this.cmbZC.Text = model.职称;
                this.cmbGJBS.Text = model.干工标识;
                this.txtPlace.Text = model.籍贯_出生地;
                this.cmbGraduation.Text = model.毕业时间文化程度;
                txtJNGZ.Text = model.技能工资.ToString();
                txtGWGZ.Text = model.岗位工资.ToString();
                txtJXGZ.Text = model.绩效工资.ToString();
                txtGLJT.Text = model.工龄津贴.ToString();
                txtKSYBX.Text = model.扣失业保险.ToString();
                txtKYLJ.Text = model.扣养老金.ToString();
                txtKYLBX.Text = model.扣医疗保险.ToString();
                txtKGJJ.Text = model.扣公积金.ToString();
                txtJNGZJB.Text = model.技能工资级别;
                txtGWGZJB.Text = model.岗位工资类别;
                txtCT.Text = model.车贴.ToString();
                txtXJJT.Text = model.星级津贴.ToString();
                txtJT1.Text = model.津贴1.ToString();
                txtJT2.Text = model.津贴2.ToString();
                txtJT3.Text = model.津贴3.ToString();
                txtJT4.Text = model.津贴4.ToString();
                txtJT5.Text = model.津贴5.ToString();
                txtKK1.Text = model.扣款1.ToString();
                txtKK2.Text = model.扣款2.ToString();
                txtKK3.Text = model.扣款3.ToString();
                txtKK4.Text = model.扣款4.ToString();
                txtKK5.Text = model.扣款5.ToString();
            }
            catch (Exception ex) { LOG.Error(ex); }




        }

        private void Form关键固定项修改_Activated(object sender, EventArgs e)
        {
            this.cmbDZZB.Text = model.党政职别;
            this.cmbZC.Text = model.职称;
            this.cmbGJBS.Text = model.干工标识;
            this.cmbGraduation.Text = model.毕业时间文化程度;

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            //this.Dispose();
            this.Close();
            
        }

        private void txtLT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtLT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtXLF_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtXLF.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtSDQBT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtSDQBT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtHT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtHT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtZCJT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtZCJT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtTGJT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtTGJT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtHCGJT_KeyPress(object sender, KeyPressEventArgs e)
        {

            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtHCGJT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtWSZF_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtWSZF.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKDSF_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKDSF.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKZAF_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKZAF.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKHF_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKHF.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKHZJ_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKHZJ.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKSZF_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKSZF.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJNGZ_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJNGZ.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtGWGZ_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtGWGZ.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJXGZ_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJXGZ.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtGLJT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtGLJT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKSYBX_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKSYBX.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKYLJ_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKYLJ.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKYLBX_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKYLBX.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKGJJ_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKGJJ.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtCT_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtCT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtXJJT_KeyPress(object sender, KeyPressEventArgs e)
        {

            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtXJJT.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJT1_KeyPress(object sender, KeyPressEventArgs e)
        {

            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJT1.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJT2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJT2.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJT3_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJT3.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJT4_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJT4.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtJT5_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtJT5.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKK1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKK1.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKK2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKK2.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKK3_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKK3.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKK4_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKK4.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }

        private void txtKK5_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 46) e.Handled = true;

            int a = txtKK5.Text.IndexOf('.');

            if (e.KeyChar == 46 && a > 0) e.Handled = true;
        }
        public bool YLBXIS_Exist()
        {
            others.key key = new others.key();

            SqlDataReader re = key.GetListYLBX(this.txtYLBX.Text.Trim(), Convert.ToInt32(others.UserHelper.GZID));
            if (re.Read())
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        public bool GJJIS_Exist()
        {
            others.key key = new others.key();

            SqlDataReader re = key.GetListGJJ(this.txtGJJ.Text.Trim(), Convert.ToInt32(others.UserHelper.GZID));
            if (re.Read())
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        public void Last_Date()
        {
            others.myGZ mygz = new myGZ();
            DataSet dataSet = mygz.GetListLastDate(this.txtBM.Text .Trim ());

            
            if ( dataSet.Tables[0].Rows.Count > 0)
            {
                this.LastDate = dataSet.Tables[0].Rows[0]["日期"].ToString();
            }
            else
            {
                this.LastDate = "9998-12-31";
            }

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                string strErr = "";
                if (this.YLBXIS_Exist())
                {
                    strErr += "医疗保险号已有,不能输入修改！\r\n";
                }
                if (this.GJJIS_Exist())
                {
                    strErr += "公积金号已有,不能输入修改！\r\n";
                }

                this.Last_Date();
                //MessageBox.Show(this.LastDate);
                DateTime time1 = this.dtpDate.Value;
                
                DateTime time2 = DateTime.Parse(this.LastDate);
                DateTime time3=DateTime.Parse("2014-07-20");

                if (DateTime.Compare(time1, time2) < 0 || DateTime.Compare(time1, time3)>0)
                {
                    strErr += "已做保护！\r\n";
                }
                if (strErr != "")
                {
                    MessageBox.Show(this, strErr);
                    return;
                }
                others.myGZ mygz = new myGZ();
               if( mygz.set0TONull()>0)
               {
                   model.部门单位 = this.txtBM.Text.Trim();
                   model.车间班组 = this.txtBZ.Text.Trim();
                   model.用工性质 = this.txtYGXZ.Text.Trim();
                   model.粮贴 =Convert .ToDecimal( this.txtLT.Text.Trim());
                   model.洗理费 = Convert.ToInt32(txtXLF.Text.Trim());
                   model.水电气补贴 = Convert.ToInt32(txtSDQBT.Text.Trim());
                   model.回贴 = Convert.ToInt32(this.txtHT.Text.Trim());
                   model.职称津贴 = Convert.ToInt32(this.txtZCJT.Text.Trim());
                   model.特岗津贴 = Convert.ToInt32(this.txtTGJT.Text.Trim());
                   model.行车工津贴 = Convert.ToInt32(txtHCGJT.Text.Trim());
                   model.行车工津贴2 = Convert.ToInt32(txtHCGJT.Text.Trim());
                   model.卫生纸费 = Convert.ToInt32(txtWSZF.Text.Trim());
                   model.扣电视费 = Convert.ToInt32(txtKDSF.Text.Trim());
                   model.扣治安费 = Convert.ToInt32(txtKZAF.Text.Trim());
                   model.扣会费 = Convert.ToDecimal(txtKHF.Text.Trim());
                   model.扣互助金 = Convert.ToInt32(txtKHZJ.Text.Trim());
                   model.扣丧葬费 = Convert.ToInt32(txtKSZF.Text.Trim());
                   model.岗位名称 = txtGW.Text.Trim();
                   model.性别 = txtSex.Text.Trim();
                   model.参加工作时间 = dtpWorkDate.Value.ToString("yyyy-MM-dd");
                   model.工号 = txtGH.Text.Trim();
                   //model.帐号=this.txtZH.Text .Trim ();
                   model.老工号 = txtLGH.Text.Trim();
                   model.出生日期 = dtpBorn.Value.ToString("yyyy-MM-dd");
                   model.党政职别 = cmbDZZB.Text.Trim();
                   model.职称 = cmbZC.Text.Trim();
                   model.干工标识 = cmbGJBS.Text.Trim();
                   model.籍贯_出生地 = txtPlace.Text.Trim();
                   model.毕业时间文化程度 = cmbGraduation.Text.Trim();
                   model.公积金号 = txtGJJ.Text.Trim();
                   model.医疗保险号 = txtYLBX.Text.Trim();
                   model.技能工资 = Convert.ToInt32(txtJNGZ.Text.Trim());
                   model.岗位工资 = Convert.ToInt32(txtGWGZ.Text.Trim());
                   model.扣失业保险 = Convert.ToDecimal(txtKSYBX.Text.Trim());
                   model.扣养老金 = Convert.ToDecimal(txtKYLJ.Text.Trim());
                   model.扣医疗保险 = Convert.ToDecimal(txtKYLBX.Text.Trim());
                   model.扣公积金 = Convert.ToInt32(txtKGJJ.Text.Trim());
                   model.技能工资级别 = txtJNGZJB.Text.Trim();
                   model.岗位工资类别 = txtGWGZJB.Text.Trim();
                   model.绩效工资 = Convert.ToInt32(txtJXGZ.Text.Trim());
                   model.工龄津贴 = Convert.ToInt32(txtGLJT.Text.Trim());
                   //model.是否保护 = "否";
                   model.车贴 = Convert.ToInt32(txtCT.Text.Trim());
                   model.星级津贴 = Convert.ToInt32(txtXJJT.Text.Trim());
                   model.星级津贴2 = Convert.ToInt32(txtXJJT.Text.Trim());
                   model.津贴1 = Convert.ToInt32(txtJT1.Text.Trim());
                   model.津贴2 = Convert.ToInt32(txtJT2.Text.Trim());
                   model.津贴3 = Convert.ToInt32(txtJT3.Text.Trim());
                   model.津贴4 = Convert.ToInt32(txtJT4.Text.Trim());
                   model.津贴4 = Convert.ToInt32(txtJT4.Text.Trim());
                   model.扣款1 = Convert.ToInt32(txtKK1.Text.Trim());
                   model.扣款2 = Convert.ToInt32(txtKK2.Text.Trim());
                   model.扣款3 = Convert.ToInt32(txtKK3.Text.Trim());
                   model.扣款4 = Convert.ToInt32(txtKK4.Text.Trim());
                   model.扣款5 = Convert.ToInt32(txtKK5.Text.Trim());


                   model.中晚班费 = model.中班 * 6 + model.晚班 * 9 + model.大晚班 * 12;
                   model.加班工资 =Convert.ToInt32( (model.技能工资 / 20.83) * model.加班);
                   model.三项补贴 = model.粮贴 + model.洗理费 + model.水电气补贴;

                   model.五项津贴 = model.津贴1 + model.津贴2 + model.津贴3 + model.津贴4 + model.津贴5;
                   model.五项扣款 = model.扣款1 + model.扣款2 + model.扣款3 + model.扣款4 + model.扣款5;
                   model.扣病假工资 =Convert.ToInt32( (((model.技能工资 + model.绩效工资) * 0.3) / 20.83) * model.病假);

                   DateTime t1 = Convert.ToDateTime(model.参加工作时间);
                   DateTime t2 = Convert.ToDateTime(model.日期);
                   int age = t2.Year - t1.Year;
                   if (t1.Month * 31 + t1.Day <= t2.Month * 31 + t2.Day)
                   {
                       age++;
                   }
                   if (age < 5) { model.扣病假工资 = Convert.ToDecimal((((model.技能工资 + model.绩效工资) * 0.3) / 20.83) * model.病假); }
                   if (age >= 5 & age < 10) { model.扣病假工资 = Convert.ToDecimal((((model.技能工资 + model.绩效工资) * 0.25) / 20.83) * model.病假); }
                   if (age >= 10 & age < 15) { model.扣病假工资 = Convert.ToDecimal((((model.技能工资 + model.绩效工资) * 0.20) / 20.83) * model.病假); }
                   if (age >= 15 & age < 20) { model.扣病假工资 = Convert.ToDecimal((((model.技能工资 + model.绩效工资) * 0.15) / 20.83) * model.病假); }
                   if (age >= 20 & age < 25) { model.扣病假工资 = Convert.ToDecimal((((model.技能工资 + model.绩效工资) * 0.10) / 20.83) * model.病假); }
                   if (age >= 25 & age < 30) { model.扣病假工资 = Convert.ToDecimal((((model.技能工资 + model.绩效工资) * 0.05) / 20.83) * model.病假); }
                   if (age >= 30) { model.扣病假工资 = 0; }
                   model.扣事假工资 = Convert.ToDecimal(((model.技能工资 + model.绩效工资) / 20.83) * model.事假);

                   model.行车工津贴 = Convert.ToInt32(model.行车工津贴 * (1 - (model.病假 + model.事假) * 0.2));
                   if (model.行车工津贴 == 0) { model.行车工津贴 = 0; }
                   model.星级津贴 =Convert.ToInt32( model.星级津贴 * (1 - (model.病假 + model.事假) * 0.1));
                   if (model.星级津贴 <= 0)
                   {
                       model.星级津贴 = 0;
                   }
                   
                   model.应发总额 = model.技能工资 + model.岗位工资 + model.绩效工资 + model.粮贴 + model.回贴 + model.洗理费 + model.水电气补贴 + model.工龄津贴 + model.职称津贴 + model.特岗津贴 + model.行车工津贴 + model.卫生纸费 + model.车贴 + model.星级津贴 + model.津贴1 + model.津贴2 + model.津贴3 + model.津贴4 + model.津贴5 + model.补发 + model.中晚班费 + model.加班工资 - model.扣病假工资 - model.扣事假工资 - model.其它扣款;

                   model.实发金额 = model.应发总额 - model.扣会费 - model.扣丧葬费 - model.扣互助金 - model.扣治安费 - model.扣电视费 - model.扣养老金 - model.扣失业保险 - model.扣医疗保险 - model.扣公积金 - model.扣款1 - model.扣款2 - model.扣款3 - model.扣款4 - model.扣款5;

                   model.应发 = model.技能工资 + model.岗位工资 + model.绩效工资 + model.粮贴 + model.回贴 + model.洗理费 + model.水电气补贴 + model.工龄津贴 + model.职称津贴 + model.特岗津贴 + model.卫生纸费 + model.补发 + model.中晚班费 + model.加班工资 - model.扣病假工资 - model.扣事假工资 - model.其它扣款;

                   model.实发 = model.应发 - model.扣会费 - model.扣丧葬费 - model.扣互助金 - model.扣治安费 - model.扣电视费 - model.扣养老金 - model.扣失业保险 - model.扣医疗保险 - model.扣公积金 - model.扣款5;
                   if (model.部门单位 == "锻造厂" | (model.部门单位 == "特钢机关" & model.车间班组 == "驻外"))
                   {
                       model.其它扣款 = model.其它扣款 + model.实发金额;
                       model.应发总额 = model.技能工资 + model.岗位工资 + model.绩效工资 + model.粮贴 + model.回贴 + model.洗理费 + model.水电气补贴 + model.工龄津贴 + model.职称津贴 + model.特岗津贴 + model.行车工津贴 + model.卫生纸费 + model.车贴 + model.星级津贴 + model.津贴1 + model.津贴2 + model.津贴3 + model.津贴4 + model.津贴5 + model.补发 + model.中晚班费 + model.加班工资 - model.扣病假工资 - model.扣事假工资 - model.其它扣款;
                       
                       model.实发金额 = model.应发总额 - model.扣会费 - model.扣丧葬费 - model.扣互助金 - model.扣治安费 - model.扣电视费 - model.扣养老金 - model.扣失业保险 - model.扣医疗保险 - model.扣公积金 - model.扣款1 - model.扣款2 - model.扣款3 - model.扣款4 - model.扣款5;
                       model.应发 = model.应发总额;
                       model.实发 = model.实发金额;
                   }

                   BLL.GZ bll = new BLL.GZ();
                   if (bll.Update(model))
                   {
                       this.flesh = true;
                       this.Close();
                   }
                   else { MessageBox.Show("修改失败！"); }


               }





            }
            catch (Exception ex) { LOG.Error(ex); System.Diagnostics.Process.Start(Application.StartupPath + "\\log\\log.txt"); }
        }




        public string 权限 { get; set; }

        public string LastDate { get; set; }

        private void btnMemo_Click(object sender, EventArgs e)
        {
            try
            {
                BLL.GZ bll = new BLL.GZ();
                model.备注 = this.txtBeiZu.Text.Trim();
                if (bll.Update(model))
                {
                    this.flesh = true;
                    this.Close();
                }
                else { MessageBox.Show("修改失败！"); }
            }
            catch (Exception ex) { LOG.Error(ex); }
        }
    }
}
